// #include <algorithm>
#include <math.h>
class Solution
{
public:
    bool judgeSquareSum(int c)
    {
        int a = 0, b = sqrt(c);
        int squareA, squareB;
        while (a <= b)
        {
            squareA = a * a;
            squareB = b * b;
            if (squareA < c - squareB)
            {
                a = a + 1;
            }
            else if (squareA > c - squareB)
            {
                b = b - 1;
            }
            else
            {
                return true;
            }
        }
        return false;
    }
};